<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>报价单</title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/list.css">
    <script>
   //检索 
   function searchListForm() {
    	var ognizationFlag = "${purchaseContract.ognizationFlag}";
    	var params = $("#searchForm").serialize();
		$.post("${ctx}/purchase/contract/searchOgnizationList?ognizationFlag="+ognizationFlag,params, function(result) {
			var listHtml = result["supplier"];
			var pageHtml = result["page"];
			$("#listHtml").html(listHtml);
			$("#paging").html(pageHtml);
			
		}, 'json');
	} 
        
 //重置
   function cleanData(){
       $("#ognizationName").val("");
       $('#ognizationCategoryCd').val('');
       $("#ognizationCategoryCd").select2(); 
       searchListForm();
   }
 
    function selectStyle() {
    	var length = $("#listHtml tr.trSelected").length;
    	if (length==0) {
    		tipParent("<spring:message code="ognization_common_pleaseChoose"/>${purchaseContract.ognizType }");
    		return false;
		}
    	var ognizationID = $("#listHtml tr.trSelected").find(".ognizationID").val();
    	var ognizationName = $("#listHtml tr.trSelected").find(".ognizationName").val();
    	var ognizationSimpleName = $("#listHtml tr.trSelected").find(".ognizationSimpleName").val();
    	var ognizationAddress = $("#listHtml tr.trSelected").find(".ognizationAddress").val();;
    	var contactPerson = $("#listHtml tr.trSelected").find(".contactPerson").val();
    	var contactPhone = $("#listHtml tr.trSelected").find(".contactPhone").val();
  		var contactFax = $("#listHtml tr.trSelected").find(".contactFax").val();
    	var contactEmail = $("#listHtml tr.trSelected").find(".contactEmail").val();
    	var legalPerson = $("#listHtml tr.trSelected").find(".legalPerson").val();
    	//获取 iframe 数量 
    	var frLength = window.parent.frames.length;
    	//父画面下标 
    	var parentIndex = frLength-2;
    	/* 采购 合同 */if ($("#frameFlg").val()==0) {
    			window.parent.frames[parentIndex].document.getElementById("ognizationIDB").value=ognizationID;
    			window.parent.frames[parentIndex].document.getElementById("ognizationNameB").value=ognizationName;
    			window.parent.frames[parentIndex].document.getElementById("ognizationShortNameB").value=ognizationSimpleName;
    			window.parent.frames[parentIndex].document.getElementById("ognizationAddressB").value=ognizationAddress;
    			window.parent.frames[parentIndex].document.getElementById("contactPersonB").value=contactPerson;
    			window.parent.frames[parentIndex].document.getElementById("contactPhoneB").value=contactPhone;
    			window.parent.frames[parentIndex].document.getElementById("contactFaxB").value=contactFax;
    			window.parent.frames[parentIndex].document.getElementById("contactEmailB").value=contactEmail;
    			window.parent.frames[parentIndex].document.getElementById("legalPersonB").value=legalPerson;
    			window.parent.frames[parentIndex].showBtn();
				closeWin();
				
		}/* 外发加工合同 */else if ($("#frameFlg").val()==1) {
        		window.parent.frames[parentIndex].document.getElementById("ognizationIDB").value=ognizationID;
        		window.parent.frames[parentIndex].document.getElementById("ognizationNameB").value=ognizationName;
        		window.parent.frames[parentIndex].document.getElementById("ognizationShortNameB").value=ognizationSimpleName;
        		window.parent.frames[parentIndex].document.getElementById("ognizationAddressB").value=ognizationAddress;
        		window.parent.frames[parentIndex].document.getElementById("contactPersonB").value=contactPerson;
        		window.parent.frames[parentIndex].document.getElementById("contactPhoneB").value=contactPhone;
        		window.parent.frames[parentIndex].document.getElementById("contactFaxB").value=contactFax;
        		window.parent.frames[parentIndex].document.getElementById("contactEmailB").value=contactEmail;
        		window.parent.frames[parentIndex].document.getElementById("legalPersonB").value=legalPerson;
        		window.parent.frames[parentIndex].showBtn();
    			closeWin();
    			

		}/* 订舱委托单  */else if ($("#frameFlg").val()==2) {
				window.parent.frames[parentIndex].document.getElementById("ognizationIDB").value=ognizationID;
				window.parent.frames[parentIndex].document.getElementById("ognizationNameB").value=ognizationName;
				window.parent.frames[parentIndex].document.getElementById("ognizationShortNameB").value=ognizationSimpleName;
				window.parent.frames[parentIndex].document.getElementById("ognizationAddressB").value=ognizationAddress
				window.parent.frames[parentIndex].document.getElementById("contactPersonB").value=contactPerson;
        		window.parent.frames[parentIndex].document.getElementById("contactPhoneB").value=contactPhone;
				closeWin();

		}/* 订单计划排期 */else if ($("#frameFlg").val()==3) {
			window.parent.frames[parentIndex].document.getElementById("ognizationID").value=ognizationID;
			window.parent.frames[parentIndex].document.getElementById("ognizationName").value=ognizationName;
    		closeWin();
    		
		}/*  发货通知单   */else if ($("#frameFlg").val()==4) {
			window.parent.frames[parentIndex].document.getElementById("ognizationIDB").value=ognizationID;
			window.parent.frames[parentIndex].document.getElementById("ognizationNameB").value=ognizationName;
			window.parent.frames[parentIndex].document.getElementById("ognizationShortNameB").value=ognizationSimpleName;
			window.parent.frames[parentIndex].document.getElementById("ognizationAddressB").value=ognizationAddress
			window.parent.frames[parentIndex].document.getElementById("contactPersonB").value=contactPerson;
    		window.parent.frames[parentIndex].document.getElementById("contactPhoneB").value=contactPhone;
			closeWin();

		}
	}
    //选择按钮事件
    function selectFunction(obj){
    	$("#listHtml tr").removeClass('trSelected');
    	$(obj).addClass('trSelected');
    	
    }
    </script>
    <style type="text/css">
    		.table-ghsno{width: 40px;}
    		.table-ghsname{width: 100px;}
		    .table-ghssimple{width: 80px;}
		    .table-ghscategory{width: 80px;}
		    .table-ghslevel{width: 80px;}
		    .table-ghsaddr{width: 110px;}
		    .table-ghsperson{width: 80px;}
		    .table-ghsphone{width: 90px;}
		    .table-ghscjz{width: 80px;}
		    .table-ghsrq{width: 80px;}
    </style>
</head>
<body style="min-width: 870px">
<form id="searchForm">
<input type = "hidden" id = "frameFlg" value="${purchaseContract.frameFlg}"/>
<input type = "hidden" id = "ognizationType" name="ognizationType" value="${purchaseContract.ognizationFlag}"/>
<div class="layerHeader clearfix" style="width: 900px">
	<p class="headerTitle"><spring:message code="ognization_common_select" />${purchaseContract.ognizType }</p>
	<div class="headerButton clearfix">
                <button type="button" onclick="searchListForm();"><spring:message code="purchaseContract_supplier_search" /></button>
                <button type="button" onclick="cleanData();"><spring:message code="common_reset" /></button>
                <button type="button" onclick="selectStyle();"><spring:message code="purchaseContract_supplier_selected" /></button>
                <button type="button" onclick="closeWin();"><spring:message code="purchaseContract_supplier_cancle" /></button>
                </div>
</div>
<div class="listArea" style="width: 900px">
<!-- 加工厂 -->
<c:if test="${purchaseContract.ognizationFlag==3 }">
	<c:set value="<%=ResourcesUtil.getConfig(\"fabricating_category\")%>" var="ognizationCategory" />
</c:if>
<!-- 供货商 -->
<c:if test="${purchaseContract.ognizationFlag==4 }">
	<c:set value="<%=ResourcesUtil.getConfig(\"supplier_category\")%>" var="ognizationCategory" />
</c:if>
<!-- 客户 -->
<c:if test="${purchaseContract.ognizationFlag==5 }">
	<c:set value="<%=ResourcesUtil.getConfig(\"customer_category\")%>" var="ognizationCategory" />
</c:if>
	<div class="listBg">
        <div class="searchArea clearfix">
            <div id="showHtml" class=" clearfix">
                <div class="searchInp clearfix">
                        <p>${purchaseContract.ognizType }</p>
                        <input type="text" class="w-customer"  id="ognizationName"  name="ognizationName"  value="" >
                    </div>
                    <c:if test="${purchaseContract.ognizationFlag!=4 }">
                    <div class="searchInp clearfix">
                   		<p>${purchaseContract.ognizType }<spring:message code="ognization_common_category"/></p>
                            <select id="ognizationCategoryCd" name="ognizationCategoryCd" class="w-styleCategory">
                            <option value=""><spring:message code="ognization_common_pleaseChoose"/></option>
                                <c:forEach items="${fns:getDictList(ognizationCategory)}" var="category">
                                    <option value="${category.itemCode}-${category.itemValue}" > 
                                        ${category.itemName}
                                    </option>
                                </c:forEach>
                            </select>
                	</div>
                	</c:if>
            </div>
                
        </div>
   
        <div class="tableArea tabBoxSm" >
            <div class="tableScroll tabSm" style="overflow: auto;height: 420px;width:860px">
                <table cellpadding="0" class="tableHead " >
                    <thead>
                    <tr>
                        <th><p class="table-ghsno"><spring:message code="common_no"/></p></th>
                                <th><p class="table-ghsname">${purchaseContract.ognizType }<spring:message code="ognization_common_name"/></p></th>
		                        <th><p class="table-ghssimple">${purchaseContract.ognizType }<spring:message code="ognization_common_simple_name"/></p></th>
		                        <th><p class="table-ghscategory">${purchaseContract.ognizType }<spring:message code="ognization_common_category"/></p></th>
		                        <th><p class="table-ghslevel">${purchaseContract.ognizType }<spring:message code="ognization_common_level"/></p></th>
		                        <th><p class="table-ghsaddr">${purchaseContract.ognizType }<spring:message code="ognization_common_address"/></p></th>
		                        <th><p class="table-ghsperson"><spring:message code="ognization_common_contact_person"/></p></th>
		                        <th><p class="table-ghsphone"><spring:message code="ognization_common_contact_phone"/></p></th>
		                        <th><p class="table-ghscjz"><spring:message code="ognization_common_creater"/></p></th>
		                        <th><p class="table-ghsrq"><spring:message code="ognization_common_create_date"/></p></th>
                    </tr>
                    </thead>
                </table>
                <table cellpadding="0" class="tableBody" >              
                    <tbody id = "listHtml">
                    
                    </tbody>
                </table>
            </div>
            
        </div>
    </div>
    <div id = "paging" ></div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
	// 下拉选框带搜索功能
    $("#ognizationCategoryCd").select2();
	searchListForm();
});
</script> 
</body>
</html>
	